package com.escope.casemanager.controller;

import com.escope.casemanager.model.HttpResult;
import com.escope.casemanager.model.SysUser;
import com.escope.casemanager.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * 登录管理接口
 * 2024/3/15
 */
@RestController
@RequestMapping("login")
@CrossOrigin
@Api(value = "登录接口", tags = {"登录接口"})
public class LoginController {
    @Autowired
    private SysUserService userService;

    @PostMapping(value = "/login")
    @ApiOperation("用户登录")
    public HttpResult login(String userCode, String password, HttpServletResponse response) throws Exception {
        return userService.accLogin(userCode, password, response);
    }

    @PostMapping(value = "/logout")
    @ApiOperation("用户登出")
    public HttpResult logout() {
        userService.logout();
        return HttpResult.ok();
    }

    @GetMapping(value = "/demo")
    public HttpResult demo(String a) throws Exception {
        return HttpResult.ok(a);
    }

    @PostMapping(value = "/demo1")
    public HttpResult demo1(@RequestBody String a) throws Exception {
        return HttpResult.ok(a);
    }
}
